package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	router := gin.Default()

	router.GET("/whats_middleware", m1, m2, handler)

	router.Run(":8080")
}

func m1(c *gin.Context) {
	fmt.Println("m1 in")
	c.Abort()
	c.Next()
	fmt.Println("m1 out")
}
func m2(c *gin.Context) {
	fmt.Println("m2 in")
	c.Next()
	fmt.Println("m2 out")
}

func handler(c *gin.Context) {
	fmt.Println("handler in")
	c.Next()
	fmt.Println("handler out")
	c.JSON(http.StatusOK, gin.H{"msg": "success"})
}
